package com.hykj.xxltest.config;

import org.apache.commons.lang.StringUtils;
import org.apache.log4j.Logger;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;

import java.io.IOException;
import java.util.Properties;

/**
 * Created by Administrator on 2017/5/22 0022.
 */
public class Config {

    private static Logger logger = Logger.getLogger(Config.class);

    public static final String rongAppKey = "vnroth0kv4ajo";//融云
    public static final String rongAppSecret = "Az3Spksx1nMiMH";//融云
    public static boolean isDebug = false;
    public static  String NoHead ;

    public static final String accessKeyId  = "LTAI7bL04hZPPcu3"; //阿里云短信
    public static final String accessKeySecret  = "vOJPb462wYudsFvYPNgPlDZA6iJXVo";

//    public static final String JPUSH_APP_KEY  = "5e8d8d70f9f4940fa4207055"; //极光推送
//    public static final String MASTER_SECRET  = "3980445c7937571d645b37d9"; //极光推送

    public static final String JPUSH_APP_KEY  = "fcf2815781bafbf9095b72d2"; //极光推送
    public static final String MASTER_SECRET  = "3b3d28a3ab2a223775018ba4"; //极光推送


    public static  String BaseUrl;
    public static  int PageSize ;
    public static  String FilePath;

    static {
        Resource resource = new ClassPathResource("base_config.properties");
        if (resource.exists()) {
            Properties properties = new Properties();
            try {
                logger.info("加载配置文件");
                properties.load(resource.getInputStream());
                BaseUrl = properties.getProperty("BaseUrl", "");
                PageSize =Integer.valueOf(properties.getProperty("PageSize", "10"));
                FilePath = properties.getProperty("FilePath", "");
                NoHead =BaseUrl+"/files/nohead.png";
            } catch (IOException e) {
                logger.error("load base_config.properties error!", e);
            }
        } else {
            logger.error("配置文件不存在");
        }
    }

    public static String photoUrl(String url){
        if(StringUtils.isNotEmpty(url)&&url.startsWith("/")){
            return BaseUrl+url;
        }
        return url;
    }

}
